<?php
session_start();
?>
<html xmlns:fb="http://ogp.me/ns/fb#">
	<head>
		<title>Art Vision</title>
		<link rel="stylesheet" type="text/css" href="css/imagen.css"/>
		<link rel="stylesheet" type="text/css" href="css/menu.css"/>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
		<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
		<script src="js/imagen.js" type="text/javascript"></script>
		<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
	</head>
	<body>
		<div id="fb-root"></div>
		<script>(function(d, s, id) {
		  var js, fjs = d.getElementsByTagName(s)[0];
		  if (d.getElementById(id)) return;
		  js = d.createElement(s); js.id = id;
		  js.src = "//connect.facebook.net/es_ES/all.js#xfbml=1";
		  fjs.parentNode.insertBefore(js, fjs);
		}(document, 'script', 'facebook-jssdk'));
		</script>
		<div id="menu_wrapper" style="display:none">
			<div id="menu" class="oscuro">
				<a href="index.php">
					<img id="logoAV" src="img/logoAV.png" alt="logo">
				</a>
				<ul>
					<li>
						<a href="./buscar.html">Buscar</a>
					</li>
					<li>
						<a href="./admin.php">Administrador</a>
					</li>
					<li>
						<a href="./readme.html">Readme</a>
					</li>
					<li>
						<p id="dialog" onclick="showDialog()">About</p>
					</li>
				</ul>
			</div>
		</div>
		<div>
			<?php include 'buscarImagen.php';
				$q=$_GET["var"];
				$response=null;
				if (strlen($q) > 0)
				{
					if (mb_check_encoding($q,'UTF-8'))
						$GLOBALS['response']=Seleccion($q);
					else
						$GLOBALS['response']=Seleccion(utf8_encode($q));
				}
				$ref="\"http://localhost/imagen.php?var=".$GLOBALS['response'][0]['PId']."\"";
					
				echo "<p id=\"nombre\">\"".utf8_decode($GLOBALS['response'][0]['NombreP'])."\" - ";
				echo "<a id=\"artista\" href=\"./resultadoBusqueda.php?artista=".utf8_decode($GLOBALS['response'][0]['Artista'])."\">".utf8_decode($GLOBALS['response'][0]['Artista'])."</a></p>";
				
				echo "<p id=\"anio\">A&ntilde;o: ".$GLOBALS['response'][0]['Anio']."</p>";
				echo "<img id=\"imagen\" src=\"./upload".$GLOBALS['response'][0]['Imagen']."\" />";
				echo "<p id=\"museo\">Museo: <a href=\"./resultadoBusqueda.php?museo=".utf8_decode($GLOBALS['response'][0]['Museo'])."\">".utf8_decode($GLOBALS['response'][0]['Museo'])."</a></p>";
				echo "<div id=\"like\">
			    <fb:like href=".$ref." send=\"false\" width=\"450\" show_faces=\"false\"></fb:like>
		        </div>";
				
				echo "<p id=\"categoria\">Categor&iacute;a: <a href=\"./resultadoBusqueda.php?categoria=".utf8_decode($GLOBALS['response'][0]['NombreC'])."\">".utf8_decode($GLOBALS['response'][0]['NombreC'])."</a></p>";
				echo "<p id=\"etiquetas\">Etiquetas relacionadas: ";
				foreach($GLOBALS['response'] as $row)
				{
					echo "<a class=\"etiqueta\" href=\"./resultadoBusqueda.php?etiqueta=".utf8_decode($row['NombreE'])."\">".utf8_decode($row['NombreE'])."</a>";
				}
				echo "</p>";
				echo "<p id=\"vistos\"> Vistos: ".$GLOBALS['response'][0]['Views']."</p>";		
				echo "<p id=\"likes\"> Likes: ".$GLOBALS['response'][0]['Likes']."<br /></p>";
				
				
				
				
			?>
		<?php
		if (isset($_SESSION['admin']))
		{
			echo "<button id=\"modificar\" onclick=\"parent.location='modificarForm.php?id=".$GLOBALS['response'][0]['PId']."'\" type=\"button\">Modificar</button>
				  <button id=\"eliminar\" onclick=\"parent.location='eliminar.php?id=".$GLOBALS['response'][0]['PId']."'\" type=\"button\">Eliminar</button>";
		}
		
		?>
		</div>
		
		
		
		<!--	<script src="/facebookLike.js" type="text/javascript"></script>-->
			<div class="fb-comments" data-href=<?php echo $ref ?> data-num-posts="2" data-width="470">
			</div>
	</body>
</html>